package priv.liaohaolong.fullstacktest.controller.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import priv.liaohaolong.fullstacktest.modal.BookDO;
import priv.liaohaolong.fullstacktest.service.BookService;

@RestController
public class BookController {

    private static final String PARAM_PAGE = "page";
    private static final String PARAM_SIZE = "size";

    private final BookService bookService;

    @Autowired
    public BookController(BookService bookService) {
        this.bookService = bookService;
    }

    @GetMapping("/api/book")
    public IPage<BookDO> getBooks(@RequestParam(PARAM_PAGE) int page, @RequestParam(PARAM_SIZE) int size) {
        return bookService.page(page, size);
    }

}
